package Management;

import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import javax.swing.ComboBoxEditor;
import javax.swing.JComboBox;
import javax.swing.JFormattedTextField;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JTextField;
import javax.swing.ListCellRenderer;
import javax.swing.text.DateFormatter;

/*
* Created on Apr 21, 2005
* Adhoc_JComboBox.java
*/

/**
* @author Mayank Joshi
*
*/
public class Adhoc_JComboBox extends JFrame implements KeyListener{

private static JComboBox combobox;
String a1,a2,a3;
public static void main(String[] args) {
new Adhoc_JComboBox();
}

private Adhoc_JComboBox(){
String array[]= new String[3];

a1=new String("a1");
a2=new String("a2");
a3=new String("a3");
array[0]= a1;
array[1]= a2;
array[2]= a3;
combobox = new JComboBox(array);
combobox.setEditable(true);
JTextField editor = (JTextField) combobox.getEditor().getEditorComponent();
editor.addKeyListener(this);
setLayout(new FlowLayout());
add(combobox);
pack();
setVisible(true);
}

/* (non-Javadoc)
* @see java.awt.event.KeyListener#keyTyped(java.awt.event.KeyEvent)
*/
public void keyTyped(KeyEvent arg0) {
System.out.println("Key Typed " +arg0.getKeyCode());
}

/* (non-Javadoc)
* @see java.awt.event.KeyListener#keyPressed(java.awt.event.KeyEvent)
*/
public void keyPressed(KeyEvent arg0) {
System.out.println("Key Pressed " +arg0.getKeyCode());
}

/* (non-Javadoc)
* @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent)
*/
public void keyReleased(KeyEvent arg0) {
System.out.println("Key Released " +arg0.getKeyCode());
}
}
